package com.sunjob.mroresource.service.impl;

import com.sunjob.common.domain.resource.*;
import com.sunjob.common.util.MROUtils;
import com.sunjob.mroresource.mapper.AccessoryMapper;
import com.sunjob.mroresource.service.AccessoryService;
import com.sunjob.mroresource.util.ResourceUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author: TomHuang
 * @date: 2022/8/22 8:18
 */

@Service
public class AccessoryServiceImpl implements AccessoryService {

    @Autowired
    private AccessoryMapper accessoryMapper;


    @Override
    public List<Accessory> selectAllAccessory() {
        return accessoryMapper.queryAllAccessory();
    }

    @Override
    public Accessory selectAccessoryById(Long accessoryId) {
        return accessoryMapper.queryAccessoryById(accessoryId);
    }

    @Override
    public List<Accessory> selectAccessoryByName(String accessoryName) {
        return accessoryMapper.queryAccessoryByName(accessoryName);
    }

    @Override
    public int selectAccessoryCount() {
        return accessoryMapper.queryAccessoryCount();
    }

    @Override
    public int insertAccessory(Accessory accessory) {
        //自动生成Id
        accessory.setAccessoryId(MROUtils.nextId());
        return accessoryMapper.insertAccessory(accessory);
    }

    @Override
    public int insertAccessorySpecies(AccessorySpecies accessorySpecies) {
        //自动生成Id
        accessorySpecies.setAccessorySpeciesId(MROUtils.nextId());
        return accessoryMapper.insertAccessorySpecies(accessorySpecies);
    }

    @Override
    public String selectAccessorySpecies(Long accessoryId) {
        return accessoryMapper.queryAccessorySpecies(accessoryId);
    }

    @Override
    public List<String> selectAllAccessorySpecies() {
        return accessoryMapper.queryAllAccessorySpecies();
    }

    @Override
    public int insertAccessoryStatus(AccessoryStatus accessoryStatus) {
        //自动生成Id
        accessoryStatus.setAccessoryStatusId(MROUtils.nextId());
        return accessoryMapper.insertAccessoryStatus(accessoryStatus);
    }

    @Override
    public int selectAccessoryStatus(Long accessoryId) {
//        Accessory accessory=accessoryMapper.queryAccessoryById(accessoryId);
        return accessoryMapper.queryAccessoryStatus(accessoryId) ;
    }

    @Override
    public List<Integer> selectAllAccessoryStatus() {
        return accessoryMapper.queryAllAccessoryStatus();
    }

    @Override
    public int insertAccessorySupplier(AccessorySupplier accessorySupplier) {
        //自动生成Id
        accessorySupplier.setAccessorySupplierId(MROUtils.nextId());
        return accessoryMapper.insertAccessorySupplier(accessorySupplier);
    }

    @Override
    public String selectAccessorySupplier(Long accessoryId) {
//        Accessory accessory=accessoryMapper.queryAccessoryById(accessoryId);
        return accessoryMapper.queryAccessorySupplier(accessoryId);
    }

    @Override
    public List<String> selectAllAccessorySupplier() {
        return accessoryMapper.queryAllAccessorySupplier();
    }

    @Override
    public int insertAccessoryTech(AccessoryTech accessoryTech) {
        //自动生成Id
        accessoryTech.setAccessoryTechId(MROUtils.nextId());
        return accessoryMapper.insertAccessoryTech(accessoryTech);
    }

    @Override
    public String selectAccessoryTech(Long accessoryId) {
        return accessoryMapper.queryAccessoryTech(accessoryId);
    }

    @Override
    public List<String> selectAllAccessoryTech() {
        return accessoryMapper.queryAllAccessoryTech();
    }

    @Override
    public int updateAccessory(Accessory accessory) {
        return accessoryMapper.updateAccessory(accessory);
    }

    @Override
    public int updateAccessorySpecies(AccessorySpecies accessorySpecies) {
        return accessoryMapper.updateAccessorySpecies(accessorySpecies);
    }

    @Override
    public int updateAccessorySupplier(AccessorySupplier accessorySupplier) {
        return accessoryMapper.updateAccessorySupplier(accessorySupplier);
    }

    @Override
    public int updateAccessoryTech(AccessoryTech accessoryTech) {
        return accessoryMapper.updateAccessoryTech(accessoryTech);
    }

    @Override
    public String selectAccessoryVehicleType(Long accessoryId) {
        return accessoryMapper.queryAccessoryVehicleType(accessoryId);
    }

    @Override
    public String selectAccessorySystem(Long accessoryId) {
        return accessoryMapper.queryAccessorySystem(accessoryId);
    }

    @Override
    public List<Inorout> selectInoroutByAccessoryId(Long accessoryId) {
        return accessoryMapper.queryInoroutByAccessoryId(accessoryId);
    }

    @Override
    public int insertAccessoryInorout(Inorout inorout) {
        //自动生成ID
        inorout.setInoroutId(MROUtils.nextId());
        //写入当前时间
        inorout.setInoroutTime(LocalDateTime.now());
        return accessoryMapper.insertAccessoryInorout(inorout);
    }

    @Override
    public int updateAccessoryCount(Long accessoryId,int count) {
        return accessoryMapper.updateAccessoryCount(accessoryId,count);
    }
}
